package com.bestcem.xm.ticket.service.manager.record;

import com.bestcem.xm.ticket.entity.mongo.TicketRecord;
import com.bestcem.xm.ticket.enums.TicketEventEnum;
import com.bestcem.xm.ticket.enums.TicketStatusEnum;
import com.bestcem.xm.ticket.service.manager.record.param.BaseTicketRecordParam;
import lombok.Getter;
import lombok.ToString;

import java.util.Objects;

/**
 * 工单进度记录 跟进/审核 信息工具类基类
 *
 * @author XiaoYunSong <ys.xiao@idiaoyan.com>
 * @version v1.0
 * @date 2021/8/18 14:59
 */
@ToString(callSuper = true)
@Getter
public abstract class BaseTicketRecord {
    /**
     * event
     */
    protected TicketEventEnum event;
    /**
     * TicketRecordId, 在调用 TicketRecordUtil#save 方法后填充
     */
    private String id;
    /**
     * orgId
     */
    private String orgId;
    /**
     * roleId
     */
    private String roleId;
    /**
     * userId
     */
    private String userId;
    /**
     * userName
     */
    private String userName;
    /**
     * regionName
     */
    private String regionName;
    /**
     * ticketId
     */
    private String ticketId;
    /**
     * source
     */
    private Integer source;
    /**
     * title
     */
    private String title;
    /**
     * content
     */
    private String content;
    /**
     * status
     */
    private TicketStatusEnum status;
    /**
     * 操作记录（工单关闭，工单转派，重新开启工单）
     */
    private String reason;

    protected BaseTicketRecord(BaseTicketRecordParam param) {
        if (Objects.nonNull(param)) {
            this.orgId = param.getOrgId();
            this.roleId = param.getRoleId();
            this.userId = param.getUserId();
            this.userName = param.getUserName();
            this.regionName = param.getRegionName();
            this.ticketId = param.getTicketId();
            this.source = param.getSource();
            this.title = param.getTitle();
            this.content = param.getContent();
            this.status = param.getStatus();
            this.event = param.getEvent();
            this.reason = param.getReason();
        }
    }

    /***
     * 跟进/审核 记录的自定义模板字段信息
     * @return 模板字段信息
     * @author XiaoYunSong <ys.xiao@idiaoyan.com>
     * @date 2021/8/19 15:38
     */
    abstract TicketRecord.CustomAttr customAttr();

    public BaseTicketRecord setId(String id) {
        this.id = id;
        return this;
    }
}
